<?php
class Ordenes_model extends CI_Model {
    public function __construct() {
        $this->load->database();
    }
    
    public function set_orden($datos) {
        $this->db->insert('ordenes', $datos);
        return $this->db->insert_id();
    }
    
    public function get_orden_por_id($id) {
        $query = $this->db->query("SELECT *
                                    FROM
                                        ordenes
                                    WHERE
                                        idorden = $id");
        return $query->row_array();
    }
    
    public function get_items_de_una_orden($idorden) {
        $query = $this->db->query("SELECT *
                                    FROM
                                        itemsorden
                                    WHERE
                                        idorden = '$idorden'");
        return $query->result_array();
    }
    
    public function set_item($datos) {
        $this->db->insert('itemsorden', $datos);
        
    }
    
    public function get_item_por_id($iditem) {
        $query = $this->db->query("SELECT *
                                    FROM
                                        itemsorden
                                    WHERE
                                        iditemsorden = $iditem");
        return $query->row_array();
    }
    
    public function delete_item($iditem) {
        $this->db->delete('itemsorden', array('iditemsorden' => $iditem));
    }
}
?>
